from sqlalchemy import (
    Column,
    Index,
    Integer,
    Text,
    Unicode,
    ForeignKey,
    Table,
    Float,
    DateTime
)
from datetime import datetime
from sqlalchemy.orm import relationship

from .meta import Base

class Item(Base):
    __tablename__='items'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(255), nullable=False)
    description = Column(Text)
    price = Column(Float, nullable=False, default=0.0)
    add_time = Column(DateTime, nullable=False, default=datetime.now())
    category_id = Column(Integer, ForeignKey('categories.id'),nullable=False)
    num=Column(Integer,default=0,nullable=False)
    category = relationship('Category', backref='items')